//'use strict';
var Chat = function (sok){
	this.sok = sok;
};
// 发送消息
Chat.prototype.sendMsg = function(room,text){
	var message = {room:room,text:text};
	this.sok.emit('message',message);
};
// 切换房间
Chat.prototype.changeRoom = function(room){
	this.socket.emit('join',{newRoom:room});
};
// 处理命令
Chat.prototype.processCommand = function(command){
	var words = command.split(' ');
	var command = words[0].substring(1,words[0].length).toLowerCase();
	var message = false;
	switch(command){
		case 'join':
			words.shift();
			var room = words.join(' ');
			this.changeRoom(room);
			break;
		case 'nick':
			words.shift();
			var name = words.join(' ');
			this.sok.emit('nameAttempt',name);
			break;
		default:
			message = 'Unresognized command.';
			break;
	}
	return message;
}
